package com.bwie.bwedu.presenter;

import com.bwie.bwedu.bean.response.MainInfoResponse;
import com.bwie.bwedu.fragment.WaittingConfirmFragment;
import com.bwie.bwedu.model.WaittingConfirmFragmentModel;
import com.bwie.bwedu.model.WaittingConfirmFragmentModelImpel;
import com.bwie.bwedu.utils.LogUtils;

/**
 * Created by zhang on 2016/7/22.
 */
public class WaitingConfrimFragmentPresenterImpl implements WaittingConfrimFragmentPresenter,WaittingConfirmFragmentModel.ValidListener, WaittingConfirmFragmentModel.Listener, WaittingConfirmFragmentModel.InvalidListener {

    private final WaittingConfirmFragmentModelImpel model;
    private WaittingConfirmFragment fragment;

    public WaitingConfrimFragmentPresenterImpl(WaittingConfirmFragment fragment) {
        this.fragment = fragment;
        model = new WaittingConfirmFragmentModelImpel();
    }

    @Override
    public void presenter(String name, String pwd) {
        //调应请求数据方法
        LogUtils.d("----------------presenter---------------------");
        model.http(name, pwd, this);
    }
    @Override
    public void valid(String id) {
        //调应请求数据方法
        model.valid(id ,this);
    }

    @Override
    public void presenter(String pwd) {
        model.Invalidhttp(pwd, this);
    }

    @Override
    public void success(MainInfoResponse userResponse) {
        fragment.onSuccess(userResponse);
    }

    @Override
    public void error(String info) {
        fragment.onFail(info);
    }

    //确认无效请求成功的方法
    @Override
    public void invalidsuccess(MainInfoResponse userResponse) {
        fragment.InvalidSuccess(userResponse);
    }

    @Override
    public void invaliderror(String info) {
        fragment.InvalidError(info);
    }

    @Override
    public void validsuccess() {
        fragment.validSuccess();
    }

    @Override
    public void validerror(String info) {
        fragment.validFail(info);
    }
}
